import http from '../../../http/http.js'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    topheight: getApp().globalData.topheight,
    details:[],
    myapiaryfalg:"",
    no_data:false
  },
  
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options){
    this.setData({
      myapiaryfalg: options.myapiary
    })
  },
  onShow: function () {
    
    this.getlist()
  },
  getlist:function(){
    http.getdata('/api/apiary/list').then((res)=>{
      
      if (res.data.result.records.length==0){
        this.setData({
          no_data: true
        })
      }else{
        this.setData({
          details: res.data.result.records,
          no_data:false
        })
      }

    })
  },
  to_details: function (e) {
    let id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '../details/details?id=' + id +'&myapiary='+this.data.myapiaryfalg,
    })
  },
  add: function () {
    wx.navigateTo({
      url: '../add/add',
    })
  },
  back:function(){
    wx.redirectTo({
      url: '../../home/home',
    })
  }
})
